package 华为OD机试B卷复用题.进阶题;

import utils.MyUtil;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;

public class HJ2_数字反转打印 {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner in = new Scanner(new File("src/main/java/华为OD机试B卷复用题/进阶题/input/2.txt"));
        MyUtil.START();
        Solution(in);
        MyUtil.END();
    }

    static void Solution(Scanner in) {
        int line = in.nextInt();
        String space_str = "    ";
        int cnt = 1;
        for(int i=1;i<=line;i++){
            int space_num = line-i;
            while(space_num-->0){
                System.out.print(space_str);
            }
            if(i%2==1){
                for(int j=cnt;j<cnt+i;j++){
                    if(j!=cnt){
                        System.out.print(space_str);
                    }
                    System.out.print(getNum(j));
                }
            }else{
                for(int j=cnt+i-1;j>=cnt;j--){
                    if(j!=cnt+i-1){
                        System.out.print(space_str);
                    }
                    System.out.print(getNum(j));
                }
            }
            System.out.println("");
            cnt += i;
        }
    }

    static String getNum(int x){
        String num = String.valueOf(x);
        for(int i=num.length();i<4;i++){
            num+="*";
        }
        return num;
    }
}
